﻿<?php 
if (!defined('WEB_ROOT')) {
	exit;
}

require_once 'functions.php';


$sql = getItemQuery($pcat, $pitem);
$result = dbQuery($sql);
$row = dbFetchAssoc($result);

$mapCol = array('bb'=>array('ten'=>'tenbb','tomtat'=>'tomtat_bb','noidung'=>'noidung_bb'),
				'dt'=>array('ten'=>'tendt','tomtat'=>'tomtat_dt','noidung'=>'noidung_dt'),
				'sm'=>array('ten'=>'chude','tomtat'=>'tomtat','noidung'=>'noidung'));
$tenCol = 'ten';
$tomtatCol = 'tomtat';

$mapTableId = array('bb'=>TABLE_BAIBAO_ID, 'dt'=>TABLE_DETAI_ID, 'sm'=>TABLE_SEMINAR_ID);
$tableId = $mapTableId[$pcat];
$itemId = $row['id'];
?>

<div class="page-all">
	<div class="page-top">
		<div class="containerI">
			<div class="sitenav">
				<a href="index.php">Trang chủ</a>&nbsp;&nbsp;»&nbsp;&nbsp;<a href="javascript:viewList('<?php echo $pcat; ?>', '<?php echo $mapCat[$pcat]; ?>')"><?php echo $mapCat[$pcat]; ?></a>&nbsp;&nbsp;»&nbsp;&nbsp;<?php echo $row[$tenCol]; ?>
			</div>
			<div class="bigdiv">
				<div id="article_content" class="post">
					<h1><?php echo $row[$tenCol]; ?></h1>
					<?php 
						$cac_tg = $row['cac_tg'];
						if ($cac_tg != NULL && $cac_tg != '')
						{
							$cac_tgid = $row['cac_tgid'];
							$tacgias = explode(",", $cac_tg);
							$tacgia_ids = explode(",", $cac_tgid);
					?>
					<p>Tác giả: 
					<?php
							for ($tgIdx = 0; $tgIdx < count($tacgias); $tgIdx++)
							{
								// bvtg: bai viet cua tac gia, ham y hien thi tat ca bai viet (bai bao / de tai) cua tac gia do
								echo "<a href='javascript:viewList(\"bvtg\", \"\", $tacgia_ids[$tgIdx]);'>$tacgias[$tgIdx]</a> ";
								if ($tgIdx < count($tacgias) - 1)
								{
									echo "- ";
								}
							}
						}
					?>
					</p>
					<?php
					if ($pcat == 'bb') {
					?>
					<p>
					Tạp chí: <? echo $row['tentc']; ?> <?php if (isset($row['so'])) echo '- Số '.$row['so']; ?> - Ngày <? echo $row['ngayra']; ?>
					</p>
					<?php
					}
					?>
					<!-- pass $tableId & $itemId to tag.php -->
					<?php require 'tag.php'; ?>
					<p><img src="images/common/article_default.jpg" width="100" height="80" class="alignleft size-medium wp-image-124"></p>
					<p class="summary">&#171;<?php echo $row[$tomtatCol]; ?>&#187;</p>
					<div class="clear"></div>
				</div>
			</div>
		</div>
	</div>
</div>
<div class="page-bottom"></div>
<div class="clear"></div>